<template>
  <el-input-number v-if="type === 'number'"
                   :style="{ width: '80px' }"
                   size="small"
                   :default-value="defaultValue"
                   @change="handleChange"/>
  <el-switch v-else
             :default-checked="defaultValue"
             size="small"
             @change="handleChange"/>
</template>

<script lang="ts" setup>
const props = defineProps({
  type: {
    type: String,
    default: '',
  },
  name: {
    type: String,
    default: '',
  },
  defaultValue: {
    type: Boolean,
    default: false,
  },
});
const emit = defineEmits(['inputChange']);
const handleChange = (value: unknown) => {
  emit('inputChange', {
    value,
    key: props.name,
  });
};
</script>
